\documentclass{ctexart}
\usepackage{listings}%插入代码
\usepackage{geometry}%设置页面大小边距等
\usepackage{graphicx}%插入图片
\usepackage{amssymb}%为了用\mathbb
\usepackage{amsmath}%数学方程的显示\usepackage{listings}%插入代码
\usepackage{fancyhdr}%设置页眉页脚
\usepackage{lastpage}%总页数
\usepackage{hyperref}%引用网页
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{float}
\usepackage{subcaption}
\usepackage{mathrsfs}



\lstset{
    basicstyle=\ttfamily, basewidth=0.5em
}


\geometry{a4paper,left=2cm,right=2cm,top=2cm,bottom=2cm}%一定要放在前面！
\pagestyle{fancy}%设置页眉页脚
\lhead{陈冠宇\ 3200102033}%页眉左
\chead{Numerical Methods for Differential Equations}%页眉中
\rhead{HW5}%章节信息
\cfoot{\thepage/\pageref{LastPage}}%当前页，记得调用前文提到的宏包
\lfoot{Zhejiang University}
\rfoot{School of Mathematical Sciences}
\renewcommand{\headrulewidth}{0.1mm}%页眉线宽，设为0可以去页眉线
\renewcommand{\footrulewidth}{0.1mm}%页脚线宽，设为0可以去页眉线
\setlength{\headwidth}{\textwidth}

\hypersetup{%设置网页链接颜色等
    colorlinks=true,%链接将会有颜色，默认是红色
    linkcolor=blue,%内部链接，那些由交叉引用生成的链接将会变为蓝色（blue）
    filecolor=magenta,%链接到本地文件的链接将会变为洋红色（magenta）
    urlcolor=blue,%链接到网站的链接将会变为蓝绿色（cyan）
    }

\newtheorem{theorem}{Theorem}
\newtheorem{proof}{Proof}
\newtheorem{solution}{Solution:}

\title{\textbf{微分方程数值解理论作业}}
\date{\today}

\begin{document}
\section*{Chapter 12}
\subsection*{\uppercase\expandafter{\romannumeral 1} Exercise 12.11}
\begin{proof}
  By definition 12.10, we have
  $$U_i^{n+1}-(rU_{i-1}^{n+1} - 2rU_i^{n+1} + rU_{i+1}^{n+1}) = rU_{i-1}^n + 2(1-r)U_i^n + rU_{i+1}^n.(i = 1,2,\cdots,m)$$
  When $i = 1$, we have $$(1+r)U^{n+1} - \frac{r}{2}U^{n+1}_2 = (1-r)U^n_1+\frac{r}{2}U^n_2+\frac{r}{2}(U_0^n+U^{n+1}_0) = (1-r)U^n_1+\frac{r}{2}U^n_2+\frac{r}{2}(g_0(t_n)+g_0(t_{n+1}))$$

  Similarly $i = m + 1$.

  Take $U^n = (U_1^n, U_2^n,\cdots, U_m^n)',\ r=\frac{k\nu}{h^2}$, then we have
  $$(I - \frac{k}{2}A)U^{n+1} = (I+\frac{k}{2}A)U^n+b^n.$$
  where $$A = \frac{\nu}{h^2}\begin{pmatrix}
    -2 & 1 & & & & \\
    1 & -2 & 1 & & & \\
     & 1& -2 & 1 & & \\
     & & \ddots & \ddots & \ddots & \\
     & & & 1 & -2 & 1\\
     & & & & 1 & -2
  \end{pmatrix}, b^n = \frac{r}{2} \begin{pmatrix}
    g_0{t_n}+g_0(t_{n+1})\\
    0\\
    \vdots\\
    0\\
    g_1(t_n)+ g_1(t_{n+1})
  \end{pmatrix}$$
\end{proof}

\subsection*{\uppercase\expandafter{\romannumeral 2} Exercise 12.26}
\begin{proof}
  By definition 12.12, we have $(I -\theta kA)U^{n+1} = (I+(1-\theta)kA)U^n + b^n$, that is
  $$U^{n+1} = (I-\theta kA)^{-1}(I+(1-\theta)kA)U^n + b^n$$
  Then $z_p = \left|\frac{1+(1-\theta)z}{1-\theta z} \right| < 1$

  Hence we have $k \leq \frac{h^2}{2(1-2\theta)\nu}$
\end{proof}

\subsection*{\uppercase\expandafter{\romannumeral 3} Exercise 12.41}
\begin{proof}
  Since we have
  $$\begin{aligned}
     &\frac{1}{\sqrt{2\pi}}\int_{-\frac{\pi}{h}}^{\frac{\pi}{h}}e^{imh\xi}\left(\frac{1}{\sqrt{2\pi}}\sum_{n\in \mathbb{Z}}e^{inh\xi}U_nh\right)d\xi\\
  =&\frac{1}{2\pi}\sum_{n\in \mathbb{Z}}\int_{-\pi}^\pi e^{-i(n-m)t}U_ndt\\
  =&\frac{1}{2\pi}\int_{-\pi}^\pi U_m dt\\
  =& U_m
  \end{aligned}$$
where $t = h\xi$, and when $n \neq m$, $\int_{-\pi}^\pi e^{-i(n - m)t}U_ndt = 0$.

That is the grid function is covered by a Fourier transform followed by an inverse Fourier transform.
\end{proof}

\subsection*{\uppercase\expandafter{\romannumeral 4} Exercise 12.48}
\begin{proof}
We can have the amplification factor
$$g(h\xi) = \frac{2(1-\theta)r(\cos(\xi h ) - 1) +1}{2\theta r(1-\cos(\xi h))+1}$$

Then we denote $z = 2r(cos(\xi h) - 1)$, then we have 
$$R(z) = \frac{1+(1-\theta  )z}{1-\theta z}$$

By Ex 12.26 when $\theta \in [\frac{1   }{2}, 1]$, we have $|R(z)| \leq 1$ for any $z<0$, that is unconditionally von Neumann stability.

When $\theta \in [0, \frac{1}{2}]$, then $z \geq \frac{2}{2\theta - 1}$, then we have 
$$2r(cos(\xi h) - 1)\geq \frac{2    }{2\theta - 1}, \forall h\xi \in [-\pi, \pi].$$

Then we have $$k \leq \frac{h^2}{2(1-2\theta)\nu}$$
  
\end{proof}

\subsection*{\uppercase\expandafter{\romannumeral 5} Exercise 12.81}
\begin{proof}
  Suppose  $a \geq 0$ , since we have $u_{t}=-a u_{x},u_{t t}=   -a u_{t x}=a^{2} u_{x x} $, then we have

$$\begin{aligned}
\tau(x, t)= & \frac{u(x, t+k)-u(x, t)}{k}+\frac{a}{2 h}(3 u(x, t)-4 u(x-h, t) \\
& +u(x-2 h, t))-\frac{a^{2} k}{2 h^{2}}(u(x, t)-2 u(x-h, t) \\
& +u(x-2 h, t)) \\
= & u_{t}+\frac{k}{2} u_{t t}+a v_{x}-\frac{a^{2} k}{2} v_{x x}+O\left(k^{2}+h^{2}\right) \\
= & O\left(k^{2}+h^{2}\right) .
\end{aligned}$$
Similarly $a < 0.$

 That is the Beam-Warming method is second-order accurate both in time and in space.
\end{proof}

\subsection*{\uppercase\expandafter{\romannumeral 6} Exercise 12.82}
\begin{solution}
  Note $$A = \begin{pmatrix}
     3 &  & & & 1& -4\\
    -4 & 3 & & & & 1\\
    1 & -4& 3 &   & & \\
     & & \ddots & \ddots & \ddots & \\
     & & 1& -4 & 3 &  \\
     & & &1 & -4 & 3
  \end{pmatrix}, B = \begin{pmatrix}
     1 &   & & &1 &-2 \\
    -2 & 1 &  & & &1 \\
     1& -2 & 1  & & & \\
     & & \ddots & \ddots & \ddots & \\
    & & 1 & -2 & 1&\\
    & & & 1 & -2 & 1
  \end{pmatrix}$$

  When $a \geq 0$, then we have
  $$U' = \frac{U^{n+1}-U^n}{k} = \frac{a}{h}(-\frac{1}{2}A+\frac{\mu}{2}B)U^n$$

  Hence
  $$z_p = k\lambda_p =-\frac{\mu}{2}\lambda_A+\frac{\mu^2}{2}\lambda_B$$
  
  We have the pics as follow and code is in untitled.m

\begin{figure}[htbp]
  \centering
  \begin{minipage}[t]{0.45\linewidth}
    \centering
    \includegraphics[width=\linewidth]{pic/1.png}
    \caption{$\mu = 0.8$}
  \end{minipage}
  \hfill
  \begin{minipage}[t]{0.45\linewidth}
    \centering
    \includegraphics[width=\linewidth]{pic/2.png}
    \caption{$\mu = 1.6$}
  \end{minipage}
\end{figure}

\begin{figure}[htbp]
  \centering
  \begin{minipage}[t]{0.45\linewidth}
    \centering
    \includegraphics[width=\linewidth]{pic/3.png}
    \caption{$\mu = 2$}
  \end{minipage}
  \hfill
  \begin{minipage}[t]{0.45\linewidth}
    \centering
    \includegraphics[width=\linewidth]{pic/4.png}
    \caption{$\mu = 2.4$}
  \end{minipage}
\end{figure}
\end{solution}

\subsection*{\uppercase\expandafter{\romannumeral 7} Exercise 12.86}
\begin{solution}
  Since $a < 0$
\\
  (1)When $\mu = 0$, then we have the upwind method $U_j^{n+1} = U_j^n$,
  hence the domain of dependence of $(x_j, t_3)$ is:

\begin{center}
  \begin{tikzpicture}
    \draw[step=1cm,gray,very thin] (0,0) grid (6,3);
    \fill (3, 0) circle (2pt);
    \fill (3, 1) circle (2pt);
    \fill (3, 2) circle (2pt);
    \fill (3, 3) circle (2pt);
    \coordinate [label=below:$x_j$] (A) at (3,0);
    \coordinate [label=left:$t_0$] (B) at (0,0);
    \coordinate [label=left:$t_3$] (C) at (0,3);
  \end{tikzpicture}
\end{center}

  (2) When $\mu = -1$, then $U_{j}^{n+1} = U_{j+1}^n$, then we have

  When $\mu = 0$, then we have the upwind method $U_j^{n+1} = U_j^n$,
  hence the domain of dependence of $(x_j, t_3)$ is:

\begin{center}
  \begin{tikzpicture}
    \draw[step=1cm,gray,very thin] (0,0) grid (6,3);
    \fill (6, 0) circle (2pt);
    \fill (5, 1) circle (2pt);
    \fill (4, 2) circle (2pt);
    \fill (3, 3) circle (2pt);
    \coordinate [label=below:$x_j$] (A) at (3,0);
    \coordinate [label=left:$t_0$] (B) at (0,0);
    \coordinate [label=left:$t_3$] (C) at (0,3);
    \coordinate [label=right:$x_{j+3}$] (D) at (6,0);
  \end{tikzpicture}
\end{center}


  (3) when $\mu = -2$, then $U^{n+1}_j = 2U^{n}_{j+1} - U_j^n$, hence we have the domain
  \begin{center}
    \begin{tikzpicture}
      \draw[step=1cm,gray,very thin] (0,0) grid (6,3);
      \fill (3, 0) circle (2pt);
      \fill (4, 0) circle (2pt);
      \fill (5, 0) circle (2pt);
      \fill (6, 0) circle (2pt);
      \fill (3, 1) circle (2pt);
      \fill (4, 1) circle (2pt);
      \fill (5, 1) circle (2pt);
      \fill (3, 2) circle (2pt);
      \fill (4, 2) circle (2pt);
      \fill (3, 3) circle (2pt);
      \coordinate [label=below:$x_j$] (A) at (3,0);
      \coordinate [label=left:$t_0$] (B) at (0,0);
      \coordinate [label=left:$t_3$] (C) at (0,3);
      \coordinate [label=right:$x_{j+3}$] (D) at (6,0);
    \end{tikzpicture}
  \end{center}

\end{solution}

\subsection*{\uppercase\expandafter{\romannumeral 8} Exercise 12.88}
\begin{solution}

  For the Lax-Wendroff method
  \\
  (1) When $\mu = 1$, we have $U^{n+1}_j = U^n_{j-1}$
  \begin{center}
    \begin{tikzpicture}
      \draw[step=1cm,gray,very thin] (0,0) grid (6,3);
      \fill (0, 0) circle (2pt);
      \fill (1, 1) circle (2pt);
      \fill (2, 2) circle (2pt);
      \fill (3, 3) circle (2pt);
      \coordinate [label=below:$x_j$] (A) at (3,0);
      \coordinate [label=left:$t_0$] (B) at (0,0);
      \coordinate [label=left:$t_3$] (C) at (0,3);
      \coordinate [label=below:$x_{j-3}$] (D) at (0,0);
    \end{tikzpicture}
  \end{center}

  (2) When $\mu = 1$, we have $U^{n+1}_j = U^n_{j+1}$
  \begin{center}
    \begin{tikzpicture}
      \draw[step=1cm,gray,very thin] (0,0) grid (6,3);
      \fill (6, 0) circle (2pt);
      \fill (5, 1) circle (2pt);
      \fill (4, 2) circle (2pt);
      \fill (3, 3) circle (2pt);
      \coordinate [label=below:$x_j$] (A) at (3,0);
      \coordinate [label=left:$t_0$] (B) at (0,0);
      \coordinate [label=left:$t_3$] (C) at (0,3);
      \coordinate [label=below:$x_{j+3}$] (D) at (0,0);
    \end{tikzpicture}
  \end{center}
\end{solution}

\subsection*{\uppercase\expandafter{\romannumeral 8} Exercise 12.97}
\begin{proof}
1. First we show that the modified equation of the leapfrog method is also 12.95.

Since the leapfrog method is $U^{n+1}_{j} = U_{j}^{n-1} - \mu (U_{j+1}^n - U^n_{j-1})$, then we replace $U^n_j$ with $v(x,t)$
$$\frac{v(x, t+k) - v(x,t - k)}{2k} = -\frac{a}{2h}(v(x+h, t) - v(x-h, t))$$\\

Second, we expand all terms in Taylor series about $(x,t)$:
$$\begin{aligned}&\frac{1}{2}\left(\frac{v(x, t+k) - v(x, t)}{k} + \frac{v(x,t) - v(x,t - k)}{k}\right) \\
  &= v_t+\frac{1}{6}k^2v_{ttt}\\
  &= -a(v_x + \frac{h^2}{6}v_{xxx})+O
\end{aligned}$$

And by $v_{ttt} = -a^3v_{xxx} + O$,
Hence $$v_t + av_x = \frac{k^2}{6}v_{ttt} -\frac{ah^2}{6}v_{xxx} + O = \frac{ah^2}{6}(\mu^2 - 1)v_{xxx} + O$$\\
2. One more term retained we have
$$v_{t}+\frac{1}{6} k^{2} v_{t t t}+\frac{1}{120} k^{4} v_{t t t t t}= -a\left(v_{x}+\frac{1}{6} h^{2} v_{x x x}+\frac{1}{120} h^{4} v_{x x x x x}\right)+O\left(k^{6}\right)$$
Since $\frac{\partial^n v}{\partial t^n} = (-a)^n\frac{\partial^n v }{\partial x^n}+O$, then we have
$$v_t+av_x + \frac{ah^2}{6}(1-\mu^2)v_{xxx}+\frac{ah^4}{120}(1-\mu^4)v_{xxxxx} = 0$$
which is equal to 12.96.

Similarly, for the method of Lax-Wendroff, since we already have $v_{tt} = a^2v_{xx} + Cv_{xxxxx}$ and 1, we can conclude that
$$v_t+av_x + \frac{ah^2}{h}(1-\mu^2)v_{xxx} = (\epsilon_f + C)v_{xxxxx} = \epsilon_wv_{xxxxx}$$
\end{proof}

\subsection*{\uppercase\expandafter{\romannumeral 8} Exercise 12.98}
\begin{proof}
1. First we prove the modified equation of Beam-Warming method $a\geq 0$.\\
By $$\begin{aligned} &\frac{v(x, t+k) - v(x,t)}{k} \\
  &= v_t + \frac{1}{2}kv_{tt}+\frac{1}{6}k^2v_{ttt}\\
  &= a\left[ -\left(\frac{2(v(x,t) - v(x-h,t))}{h} + \frac{v(x-2h, t) - v(x,t)}{2h}\right) - \mu\left(\frac{v(x,t) - v(x-h,t)}{h} + \frac{v(x-2h, t) - v(x,t)}{h}\right) \right] \\
  &= a\left[-v_t +\frac{h^2}{3}v_{xxx} + \mu (\frac{1}{2}v_{xx}+\frac{1}{2}h^2v_{xxx})\right]
\end{aligned}$$\\

By $\frac{\partial^n v}{\partial t^n} = (-a)^n\frac{\partial^n v }{\partial x^n}+O$, hence we have
$$ v_{t}+a v_{x} - \frac{ah^2}{6}\left(2-3\mu+\mu^2\right) v_{x x x} = +O\left(k^{3}\right) .$$

Thus we have $a_1 = a, a_3 = - \frac{ah^2}{6}(\mu-1)(\mu-2)$, Therefore
$$\omega(\xi) = a_1\xi + a_3\xi^3 = a\xi - \frac{ah^2}{6}(\mu-1)(\mu-2)\xi^3$$
\\
That is
$$\begin{aligned}
  &C_p(\xi) = \frac{\omega(\xi)}{\xi} = a + \frac{ah^2}{6}(\mu-1)(\mu-2)\xi^2\\
  &C_g(\xi) = \frac{d\omega}{d\xi} = a + \frac{ah^2}{2}(\mu-1)(\mu-2)\xi^2
\end{aligned}$$
\end{proof}

\subsection*{\uppercase\expandafter{\romannumeral 8} Exercise 12.99}
\begin{proof}
If $\mu  = 1$, then the Lax-Wendroff method has 
$$U^{n+1}_j = U^{n}_{j-1}$$
If $U^n$ is exact, then $U^{n+1}$ is exact. Hence the Lax-Wendroff gives the exact solution at grid points. That is better than $k = 0.8h$.

Similarly the leapfrog method is exact, which answers (f).
\end{proof}
\subsection*{\uppercase\expandafter{\romannumeral 7} Exercise 12.101}
\begin{proof}
  Since the Lax-Friedrichs method is
  $$U^{n+1}_j = (\frac{1}{2}-\frac{\mu}{2})U^n_{j+1} + (\frac{1}{2}+\frac{\mu}{2})U^n_{j-1}$$
\\
  then $$\chi_j(h\xi) = (\frac{1}{2}-\frac{\mu}{2})e^{i(j+1)\xi}+(\frac{1}{2}+\frac{\mu}{2})e^{i(j-1)h\xi}$$
\\
  Hence $$g(h\xi) = \frac{1-\mu}{2}e^{ih\xi} + \frac{1+\mu}{2}e^{ih\xi} = cos(h\xi) + \mu i\sin(h\xi)$$\\
  \\
  Therefore
  $$\begin{aligned}
    \left|g(\xi)\right|^2 &= \cos^2(h\xi) + \mu^2\sin^2(h\xi)\\
    &= (\mu^2 - 1)\sin^2(h\xi) + 1 \leq 1
  \end{aligned}$$
  Hence $\mu^2 - 1 = 0$, that is the method is stable provided $\mu \leq 1$.
\end{proof}

\subsection*{\uppercase\expandafter{\romannumeral 7} Exercise 12.102}
\begin{proof}
  Since the Lax-Wendroff method is
  $$U^{n+1}_j = (1-\mu^2)U^n_j + \frac{\mu^2 - \mu}{2}U^n_{j+1}+\frac{\mu^2_\mu}{2}U_{j-1}^n$$
\\
  Hence $$\begin{aligned}
    g(h\xi) &= 1 - \mu^2 + \frac{\mu^2- \mu}{2}e^{ih\xi} + \frac{\mu^2 + \mu}{2}e^{-ih\xi}\\
    & = 1-2\mu^2\sin^2(\frac{h\xi}{2}) - i\mu \sin(h\xi)
  \end{aligned}$$\\
  \\
  Therefore
  $$\begin{aligned}
    \left|g(\xi)\right|^2 &= (1-2\mu^2\sin^2(\frac{h\xi}{2}))^2 + \mu^2\sin^2(h\xi)\\
    &= 1 + 4\mu^2(mu^2 - 1)\sin(\frac{h\xi}{2}) \leq 1
  \end{aligned}$$
  Hence $\mu^2 - 1 = 0$, that is the method is stable provided $\mu \leq 1$.
\end{proof}
\end{document}
